package com.wtu.sys.servlet;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.wtu.bean.Academy;
import com.wtu.bean.Course;
import com.wtu.bean.Hobby;
import com.wtu.bean.Manage;
import com.wtu.bean.Result;
import com.wtu.bean.Student;

public class SendInfo{

	public static void rePageAcademy(HttpServletRequest request, List<Academy> academyList, String msg) {
		if("".equals(msg)){
			msg="<table>";
			for (Academy academy : academyList) {
				msg+=WriteInfo.write(academy);
			}
			msg+="</table>";			
		}else{
			msg="<span>"+msg+"</span>";
		}
		request.setAttribute("msg", msg);
	}
	
	public static void rePageCourse(HttpServletRequest request, List<Course> courseList, String msg) {
		if("".equals(msg)){
			msg="<table>";
			for (Course course : courseList) {
				msg+=WriteInfo.write(course);
			}
			msg+="</table>";			
		}else{
			msg="<span>"+msg+"</span>";
		}
		request.setAttribute("msg", msg);
	}
	
	public static void rePageHobby(HttpServletRequest request, List<Hobby> hobbyList, String msg) {
		if("".equals(msg)){
			msg="<table>";
			for (Hobby hobby : hobbyList) {
				msg+=WriteInfo.write(hobby);
			}
			msg+="</table>";			
		}else{
			msg="<span>"+msg+"</span>";
		}
		request.setAttribute("msg", msg);
	}
	
	public static void rePageManage(HttpServletRequest request, List<Manage> manageList, String msg) {
		if("".equals(msg)){
			msg="<table>";
			for (Manage manage : manageList) {
				msg+=WriteInfo.write(manage);
			}
			msg+="</table>";			
		}else{
			msg="<span>"+msg+"</span>";
		}
		request.setAttribute("msg", msg);
	}
	
	public static void rePageResult(HttpServletRequest request, List<Result> resultList, String msg) {
		if("".equals(msg)){
			msg="<table>";
			for (Result result : resultList) {
				msg+=WriteInfo.write(result);
			}
			msg+="</table>";			
		}else{
			msg="<span>"+msg+"</span>";
		}
		request.setAttribute("msg", msg);
	}
	
	public static void rePageStudent(HttpServletRequest request, List<Student> studentList, String msg) {
		if("".equals(msg)){
			msg="<table>";
			for (Student student : studentList) {
				msg+=WriteInfo.write(student);
			}
			msg+="</table>";			
		}else{
			msg="<span>"+msg+"</span>";
		}
		request.setAttribute("msg", msg);
	}
	
}
